package com.inno.subject.infra.basic.mapper;

import com.github.pagehelper.Page;
import com.inno.subject.infra.basic.entity.PlannerSubjectRecords;
import com.inno.subject.infra.entity.RankCountBO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * (PlannerSubjectRecords)表数据库访问层
 *
 * @author makejava
 * @since 2024-11-16 20:57:05
 */
public interface PlannerSubjectRecordsDao {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    PlannerSubjectRecords queryById(Long id);

    /**
     * 统计总行数
     *
     * @param plannerSubjectRecords 查询条件
     * @return 总行数
     */
    long count(PlannerSubjectRecords plannerSubjectRecords);

    /**
     * 新增数据
     *
     * @param plannerSubjectRecords 实例对象
     * @return 影响行数
     */
    int insert(PlannerSubjectRecords plannerSubjectRecords);

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<PlannerSubjectRecords> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<PlannerSubjectRecords> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<PlannerSubjectRecords> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<PlannerSubjectRecords> entities);

    /**
     * 修改数据
     *
     * @param plannerSubjectRecords 实例对象
     * @return 影响行数
     */
    int update(PlannerSubjectRecords plannerSubjectRecords);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(Long id);

    List<RankCountBO> queryTotalCountGroupUserId();

    List<PlannerSubjectRecords> queryByUserIdAndSubjectIdList(@Param("userId") Long currentUser, @Param("subjectIdList") List<Long> subjectIdList);

    Page<PlannerSubjectRecords> queryPage(PlannerSubjectRecords plannerSubjectRecords);

    Page<PlannerSubjectRecords> queryErrorSubjectId(PlannerSubjectRecords records);

    List<Long> queryCountGroupSubjectId(Long currentUser);

    void deleteBatch(@Param("idList") List<Long> needDeleteList);
}

